package com.hqq.structure.composite;

/**
 * Tree
 * 组合模式（Composite）
 * 将多个对象组合在一起进行操作，常用于表示树形结构中
 * Created by heqianqian on 2017/3/11.
 */
public class Tree {

    TreeNode root = null;

    public Tree(String name) {
        root = new TreeNode(name);
    }

    public static void main(String[] args) {
        Tree tree = new Tree("A");
        TreeNode nodeB = new TreeNode("B");
        TreeNode nodeC = new TreeNode("C");

        nodeB.addTreeNode(nodeC);
        tree.root.addTreeNode(nodeB);
        System.out.println("build the tree finished!");
    }
}
